package com.trhui.mallbook.client;

import com.trhui.mallbook.domain.common.ApiRequest;
import com.trhui.mallbook.domain.common.BaseResponse;
import com.trhui.mallbook.domain.request.dg.DgWithdrawRequest;
import com.trhui.mallbook.domain.request.hf.HfWithdrawRequest;
import com.trhui.mallbook.domain.request.xib.XibWithdrawRequest;
import com.trhui.mallbook.domain.request.yb.YbWithdrawRequest;
import com.trhui.mallbook.domain.response.dg.DgWithdrawResponse;
import com.trhui.mallbook.domain.response.hf.HfWithdrawResponse;
import com.trhui.mallbook.domain.response.xib.XibWithdrawResponse;
import com.trhui.mallbook.domain.response.yb.YbWithdrawResponse;
import com.trhui.mallbook.enums.ChannelTypeEnum;
import com.trhui.mallbook.enums.ServerCodeEnum;

/**
 * @author huangh
 * @version 1.0
 * @description 结算接口
 * @date 2023/08/17 0017 9:22
 */

public class WithdrawClient extends AbstractClient {

    /**
     * 汇付-结算
     * 
     * @param request
     * @return
     */
    public static BaseResponse<HfWithdrawResponse> hfWithdraw(HfWithdrawRequest request) {
        ApiRequest reqApiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.WITHDRAW)
                .channelType(ChannelTypeEnum.HF)
                .build();
        return post(reqApiRequest, HfWithdrawResponse.class);
    }

    /**
     * 易宝-结算
     * 
     * @param request
     * @return
     */
    public static BaseResponse<YbWithdrawResponse> ybWithdraw(YbWithdrawRequest request) {
        ApiRequest reqApiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.WITHDRAW)
                .channelType(ChannelTypeEnum.YB)
                .build();
        return post(reqApiRequest, YbWithdrawResponse.class);
    }

    /**
     * 厦门国际银行-结算
     * 
     * @param request
     * @return
     */
    public static BaseResponse<XibWithdrawResponse> xibWithdraw(XibWithdrawRequest request) {
        ApiRequest reqApiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.WITHDRAW)
                .channelType(ChannelTypeEnum.XIB)
                .build();
        return post(reqApiRequest, XibWithdrawResponse.class);
    }

    /**
     * 斗拱-结算
     * 
     * @param request
     * @return
     */
    public static BaseResponse<DgWithdrawResponse> dgWithdraw(DgWithdrawRequest request) {
        ApiRequest reqApiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.WITHDRAW)
                .channelType(ChannelTypeEnum.DG)
                .build();
        return post(reqApiRequest, DgWithdrawResponse.class);
    }

}
